<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>SSE handler</title>
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="">

<body>
  <h1>Server send event</h1>
  <script lang="javascript">
    let token = 'eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3Mjg3Mzc3MTcsImV4cCI6MTcyOTM0MjUxNywibmJmIjoxNzI4NzM3NzE3LCJpc3MiOiJjaGF0X3NlcnZlciIsImF1ZCI6ImNoYXRfd2ViIiwiaWQiOjM5LCJmdWxsbmFtZSI6InhpYW96aSIsImVtYWlsIjoieGlhb3ppQHFxLmNvbSIsIndzX2lkIjoxNSwicGFzc3dvcmRfaGFzaCI6bnVsbCwidXBkYXRlZF9uYW1lIjoiU1lTVEVNIiwiY3JlYXRlZF9uYW1lIjoiU1lTVEVNIn0.pzJJD0JNxvvMfoTWhE_bwXBHRBxMf4SfnHwPE5rvjSOSRboimmHW1mFBlhrWkD7e9E6EhzV1GC-49LfvCg5kDw';
    var source = new EventSource(`/events?access_token=${token}`);

    source.onmessage = function (event) {
      console.log("Got:", event.data);
    };
    source.addEventListener("NewChat", function (event) {
      console.log("NewChat:", event.data);
    });
    source.addEventListener("AddToChat", function (event) {
      console.log("AddToChat:", event.data);
    });
    source.addEventListener("RemoveFromChat", function (event) {
      console.log("RemoveFromChat:", event.data);
    });
    source.addEventListener("ChatMessage", function (event) {
      console.log("ChatMessage:", event.data);
    });
  </script>
</body>
</head>

</html>
